package com.yiqi.liebang.feature.home.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.liebang.entity.bo.QuestionBo;
import com.yiqi.liebang.entity.bo.SearchBo;
import com.yiqi.liebang.entity.bo.TopicBo;
import com.yiqi.liebang.entity.bo.TopicListBo;
import com.yiqi.liebang.feature.home.contract.QuestionContract;
import com.yiqi.liebang.feature.home.contract.TopicContract;
import com.yiqi.liebang.feature.home.dependencies.question.DaggerQuestionModelComponent;
import com.yiqi.liebang.feature.home.dependencies.topic.DaggerTopicModelComponent;
import com.yiqi.liebang.framework.api.ApiLib;
import com.yiqi.liebang.framework.api.HomeApi;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

public class QuestionModel implements QuestionContract.Model {

    @Inject
    HomeApi api;


    @Inject
    public QuestionModel() {
        DaggerQuestionModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<List<QuestionBo>> getQuestionList(TopicListBo workBo) {
        return api.getQuestionList(workBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<List<QuestionBo>> questionQuestion(SearchBo searchBo) {
        return api.searchQuestion(searchBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<List<QuestionBo>> getOtherQuestionList(SearchBo searchBo) {
        return api.getOtherTopic(searchBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
